Assessment of episodes of drug use and psychosocial stress is complicated by the fact that each is often transient and difficult to recall accurately. Assessment of their causal connections with one another, and of their genetic and environmental determinants, is complicated by the complexity of the causal connections and by the elusive nature of what constitutes the environment. In this project, we are assessing drug use and psychosocial stress in near-real time through ecological momentary assessment (EMA), in which participants use handheld electronic diaries to record events as they occur and to report recent or ongoing events in response to randomly timed prompts throughout the day. We are also maintaining real-time records of where the reported events occur by having participants carry GPS loggers to track their whereabouts with a spatial resolution of several meters. We use these data collectively in a method we are calling geographical momentary assessment (GMA). Our goal with GMA has little to do with knowing the specific Baltimore locations where drug-related behaviors occur, and everything to do with gaining generalizable knowledge about how activity spaces (the spaces in which daily activities occur) are associated with such behaviors and their precipitants. We are currently analyzing GMA data from 190 opioid/cocaine users in opioid-agonist maintenance. This sample, much larger than our initial pilot sample, will enable us to investigate the relationships among individual characteristics and environmental influences on drug use. We are also developing more sophisticated methods for interpolating observer ratings between specific rated locations, better approaches to the generation of scores and maps from raw observer rating scores, and more sensitive approaches to modeling associations between momentary surroundings and mood, craving, and stress. In the first 97 participants, we examined the relationship between stressful events and drug use. We demonstrated that, in a subset of patients, the severity of stressful events increases in the days leading up to cocaine use, though stressful events are neither necessary nor sufficient to account for many drug-use eventsa finding that underscores the importance of assessing base rates of events in order to avoid inflated estimates of association. We have recently begun to collect these types of data in non-drug users living in Baltimore to determine whether they experience similar responses to environmental variables. As part of this larger trial, we collaborated with the developers of AutoSense, a wearable wireless sensor system that continuously measures heart rate, heart-rate variability, respiration, skin conductance, ambient temperature, and physical activity; data are collected by biosensors and transmitted to a smartphone. Data from our study and from other AutoSense collaborations were used to develop algorithms that can detect drug use, smoking, and stress. We field-tested AutoSense in 40 polydrug users during methadone maintenance; they wore AutoSense for 4 one-week periods, during which they also self-reported drug use, stressful events, mood, and activities via EMA. Urine drug screens were conducted 3 times weekly. In prior analyses, we had developed an algorithm to detect cocaine use from heartrate data. We have now focused on detection of stress, using a time-series pattern-mining method we developed. We found that the duration of a stress episode predicts the duration of the next stress episode and that stress is lower in the mornings and evenings than during the day. We also found relationships between detected stress and objectively, independently rated disorder in the surrounding neighborhood, and we developed a model to predict stressful episodes for proactive interventions. One of our other mHealth activities is evaluation of the effects of drug use on circadian rhythm and sleep. We are currently analyzing data from a mobile device that monitors light exposure and activity to assess circadian disruption and its relation to treatment outcome. We are also conducting a study of sleep in opioid-maintained outpatients with and without chronic pain.